package com.vcredit.creditcat.util;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vcredit.framework.util.JacksonUtil;

import java.util.Map;


public class JsonUtil extends JacksonUtil{

	public static String obj2Json(Object obj,boolean ignoreNull) throws JsonProcessingException {
		if(ignoreNull) {
			ObjectMapper mapper = new ObjectMapper();
			mapper.setSerializationInclusion(Include.NON_NULL);  
			return mapper.writeValueAsString(obj);
		}
		return Obj2Json(obj);
	}
	public static Map json2Map(String json){
		Map map=JSON.parseObject(json,Map.class);
		return map;
	}
}
